package com.sdhs.costcontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.costcontrol.domain.GcControlFinalAccounts;
import com.sdhs.costcontrol.service.IGcControlFinalAccountsService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 项目决算Controller
 * 
 * @author wanglei
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/costcontrol/finalAccounts")
public class GcControlFinalAccountsController extends BaseController
{
    @Autowired
    private IGcControlFinalAccountsService gcControlFinalAccountsService;

    /**
     * 查询项目决算列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcControlFinalAccounts gcControlFinalAccounts)
    {
        startPage();
        List<GcControlFinalAccounts> list = gcControlFinalAccountsService.selectGcControlFinalAccountsList(gcControlFinalAccounts);
        return getDataTable(list);
    }

    /**
     * 导出项目决算列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:export')")
    @Log(title = "项目决算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcControlFinalAccounts gcControlFinalAccounts)
    {
        List<GcControlFinalAccounts> list = gcControlFinalAccountsService.selectGcControlFinalAccountsList(gcControlFinalAccounts);
        ExcelUtil<GcControlFinalAccounts> util = new ExcelUtil<GcControlFinalAccounts>(GcControlFinalAccounts.class);
        util.exportExcel(response, list, "项目决算数据");
    }

    /**
     * 获取项目决算详细信息
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcControlFinalAccountsService.selectGcControlFinalAccountsById(id));
    }

    /**
     * 新增项目决算
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:add')")
    @Log(title = "项目决算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcControlFinalAccounts gcControlFinalAccounts)
    {
        return toAjax(gcControlFinalAccountsService.insertGcControlFinalAccounts(gcControlFinalAccounts));
    }

    /**
     * 修改项目决算
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:edit')")
    @Log(title = "项目决算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcControlFinalAccounts gcControlFinalAccounts)
    {
        return toAjax(gcControlFinalAccountsService.updateGcControlFinalAccounts(gcControlFinalAccounts));
    }

    /**
     * 删除项目决算
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:finalAccounts:remove')")
    @Log(title = "项目决算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcControlFinalAccountsService.deleteGcControlFinalAccountsByIds(ids));
    }
}
